﻿using AJWPFAdmin.Core.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace AJWPFAdmin.Core.Converters
{
    public class StoreTypeToBooleanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is CarIdentificationConfig.StoreType type)
            {
                return type.ToString().Equals(parameter?.ToString() ?? string.Empty);
            }
            return false;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (Enum.TryParse<CarIdentificationConfig.StoreType>(parameter?.ToString(), out var type))
            {
                return type;
            }
            return null;
        }
    }
}
